package com.whp.service.impl;

import com.whp.bean.Person;
import com.whp.service.MessageService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wanghp
 * @version 1.0
 * @date 2020/6/4 16:35
 */
public class PersonFactoryBean implements FactoryBean<Person> {
	protected final Log logger = LogFactory.getLog(getClass());

	private String personInfo;

	public String getPersonInfo() {
		return personInfo;
	}

	public void setPersonInfo(String personInfo) {
		this.personInfo = personInfo;
	}

	@Override
	public Person getObject() throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("进入getObject");
		}
		logger.info("进入getObject");
		Person person = new Person();
		String[] split = personInfo.split(",");
		person.setName(split[0]);
		person.setAge(Integer.parseInt(split[1]));
		return person;
	}

	@Override
	public Class<?> getObjectType() {
		logger.info("进入getObjectType");
		return Person.class;
	}
}
